// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false
import axios from "axios"
Vue.prototype.$axios = axios;
import qs from 'qs'
Vue.use(ElementUI);
Vue.prototype.bus = new Vue();
import { Message } from 'element-ui';

router.beforeEach((to, from, next) => {
  let cookie = localStorage.getItem('shopPC')
  if (!cookie) {
    if (to.path == '/'||to.path == '/register'||to.path == '/registerw') {
      next();
    } else {
      next('/');
    }
  } else {   
    if(to.path=='/person'){
      let user = JSON.parse(localStorage.getItem('userInfo')).account_type
      if(user==1){
        Message.error('暂无权限');
      }else{
        next()
      }
    }else{
      next()
    }
    
  }
})

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
